<?php

namespace App\Services;

use App\Commons\CommonConstant;
use App\Models\Channels;

class ChannelService extends ServiceBase
{
    public function one($channel)
    {
        $one = Channels::where('channel', $channel)->first();
        if (empty($one)) {
            return false;
        }
        return $one->toArray();
    }

    /**
     * 获取当前渠道
     * @param $params
     * @return int
     */
    public function getChannel($params)
    {
        if (!isset($params['channel']) && (empty($params['channel']) || is_string($params['channel']))) {
            return CommonConstant::DEFAULT_CHANNEL;
        }

        return $params['channel'];
    }
}
